#include<bits/stdc++.h>
using namespace std;
int const maxn=1e5+5;
struct node{
    int l,r;
    bool operator<(const node&A)const{
        return r<A.r;
    }
}lim[maxn];
int d[maxn],v0[maxn],a[maxn],p[maxn];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    scanf("%d",&t);
    while(t--){
        int n,m,l,V;
        scanf("%d%d%d%d",&n,&m,&l,&V);
        V=V*V;
        for(int i=1;i<=n;i++)scanf("%d%d%d",d+i,v0+i,a+i),v0[i]=v0[i]*v0[i];
        for(int i=1;i<=m;i++)scanf("%d",p+i);
        int cnt=0;
        for(int i=1;i<=n;i++){
            int x,k=lower_bound(p+1,p+1+m,d[i])-p;
            if(k>m)continue;
            if(a[i]==0){
                if(v0[i]<=V)continue;
                lim[++cnt]=node{k,m};
            }
            else if(a[i]>0){
                if(v0[i]+2*a[i]*(l-d[i])<=V)continue;
                x=d[i]+(V-v0[i])/2/a[i];
                k=upper_bound(p+1,p+1+m,x)-p;
                if(k<=m)lim[++cnt]=node{k,m};
            }
            else{
                if(v0[i]<=V)continue;
                if(v0[i]+2*a[i]*(p[m]-d[i])>V)lim[++cnt]=node{k,m};
                else{
                    x=d[i]+ceil((v0[i]-V)/2.0/(-a[i]));
                    x=lower_bound(p+1,p+1+m,x)-p-1;
                    if(k<=x)lim[++cnt]=node{k,x};
                }
            }
        }
        int ans=0,lst=0;
        sort(lim+1,lim+1+cnt);
        for(int i=1;i<=cnt;i++){
            if(lim[i].l>lst)ans++,lst=lim[i].r;
        }
        printf("%d %d\n",cnt,m-ans);
    }
}